<!DOCTYPE html>
<?php

use yii\helpers\Html;
use yii\helpers\Url;

$isGuest = Yii::$app->user->isGuest;
if ($isGuest) {
	
} else {
	$cartTotal = $this->params['cartTotal'];
	$cartList = $this->params['cartList'];
	$cartCount = $this->params['cartCount'];
}
$categoryList = $this->params['categoryList2'];
?>
<html lang="en">
    <head>
        <!-- Meta -->
        <meta charset="utf-8">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
        <meta name="description" content="">
        <meta name="author" content="">
        <meta name="keywords" content="MediaCenter, Template, eCommerce">
        <meta name="robots" content="all">

        <title>桂智商城</title>

        <!-- Bootstrap Core CSS -->
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/bootstrap.min.css">

        <!-- Customizable CSS -->
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/main.css">
        <!--<link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/green.css">-->
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/orange.css">
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/owl.carousel.css">
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/owl.transitions.css">
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/animate.min.css">

        <!-- Demo Purpose Only. Should be removed in production -->
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/config.css">

        <!--<link href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/green.css" rel="alternate stylesheet" title="Green color">-->
        <!--<link href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/blue.css" rel="alternate stylesheet" title="Blue color">-->
        <!--<link href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/red.css" rel="alternate stylesheet" title="Red color">-->
        <!--<link href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/orange.css" rel="alternate stylesheet" title="Orange color">-->
        <!--<link href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/navy.css" rel="alternate stylesheet" title="Navy color">-->
        <!--<link href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/dark-green.css" rel="alternate stylesheet" title="Darkgreen color">-->
        <!-- Demo Purpose Only. Should be removed in production : END -->

        <!-- Fonts -->
        <!--<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800' rel='stylesheet' type='text/css'>-->

        <!-- Icons/Glyphs -->
        <link rel="stylesheet" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/css/font-awesome.min.css">

        <!-- Favicon -->
        <link rel="shortcut icon" href="<?= Yii::$app->urlManager->baseUrl ?>/assets/images/favicon.ico">

        <!-- HTML5 elements and media queries Support for IE8 : HTML5 shim and Respond.js -->
        <!--[if lt IE 9]>
                <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/html5shiv.js"></script>
                <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/respond.min.js"></script>
        <![endif]-->


    </head>
    <body>

        <div class="wrapper">
            <!-- ============================================================= TOP NAVIGATION ============================================================= -->
            <nav class="top-bar animate-dropdown">
                <div class="container">
                    <div class="col-xs-12 col-sm-6 no-margin">
                        <ul>
                            <li><a href="<?php echo \yii\helpers\Url::toRoute('site/index'); ?>">首页</a></li>
                        </ul>
                    </div><!-- /.col -->

                    <div class="col-xs-12 col-sm-6 no-margin">
                        <ul class="right">
							<?php
							if (Yii::$app->user->isGuest) {
								?>
																	<!--<li><a href=<?= yii\helpers\Url::toRoute('site/signup'); ?>>免费注册</a></li>-->
								<li><a href = <?= yii\helpers\Url::toRoute('site/login'); ?>>你好，请登录</a></li>
								<?php
							} else {
								echo '<li>'
								. Html::beginForm(['/site/logout'], 'post')
								. Html::submitButton(
										'注销 (' . Yii::$app->user->identity->username . ')', ['class' => 'btn btn-link']
								) . Html::endForm() . '</li>';
							}
							?>
							<li><a href="<?php echo Url::toRoute('user/profile'); ?>">我的桂智</a></li>
                            <li><a href="<?php echo Url::toRoute('shop-order/index'); ?>">我的订单</a></li>
                            <li><a href="#">我的商城</a></li>
                            <li><a href="#">企业采购</a></li>
                            <li><a href="#">客户服务</a></li>
                        </ul>
                    </div><!-- /.col -->
                </div><!-- /.container -->
            </nav><!-- /.top-bar -->
            <!-- ============================================================= TOP NAVIGATION : END ============================================================= -->		<!-- ============================================================= HEADER ============================================================= -->
            <header class="no-padding-bottom header-alt">
                <div class="container no-padding">

                    <div class="col-xs-12 col-md-3 logo-holder">
                        <!-- ============================================================= LOGO ============================================================= -->
                        <div class="logo">
                            <a href="<?= Yii::$app->urlManager->baseUrl ?>/site/index">
								<img alt="http://ofy6hewql.bkt.clouddn.com/logo2.png" src="http://ofy6hewql.bkt.clouddn.com/logo2.png" width="auto" height="auto"/>
                            </a>
                        </div><!-- /.logo -->
                        <!-- ============================================================= LOGO : END ============================================================= -->		</div><!-- /.logo-holder -->

                    <div class="col-xs-12 col-md-6 top-search-holder no-margin">
                        <div class="contact-row">
                            <div class="phone inline">
                                <i class="fa fa-phone"></i> (+86) 15607830691
                            </div>
                            <div class="contact inline">
                                <i class="fa fa-envelope"></i> 898601566@<span class="le-color">qq.com</span>
                            </div>
                        </div><!-- /.contact-row -->
                        <!-- ============================================================= SEARCH AREA ============================================================= -->
                        <div class="search-area">
                            <form id="productSearch" method="get" action="<?php echo Url::toRoute('product/search') ?>">
                                <div class="control-group">
                                    <input name="searchString" class="search-field" placeholder="搜索商品" />
									<!--<input id="_csrf" name="_csrf" type="hidden" value="<?php echo Yii::$app->request->csrfToken ?>"/>-->
                                    <ul class="categories-filter animate-dropdown">
                                        <li class="dropdown">
                                            <a class="dropdown-toggle"  data-toggle="dropdown" href="category-grid.html">所有分类</a>
                                            <ul class="dropdown-menu" role="menu" >
												<?php foreach ($categoryList as $key => $categoryUnit) { ?>
													<li role="presentation">
														<a role="menuitem" tabindex="-1" href="
														<?php
														echo Url::toRoute(['product/search', 'categoryId' =>
															$key]);
														?>"><?php echo$categoryUnit[0] ?>
														</a>
													</li>
												<?php } ?>
                                            </ul>
                                        </li>
                                    </ul>
                                    <a class="search-button" href="#" onclick="doSearch()"></a>    
                                </div>
                            </form>
                        </div><!-- /.search-area -->
                        <!-- ============================================================= SEARCH AREA : END ============================================================= -->		</div><!-- /.top-search-holder -->

                    <div class="col-xs-12 col-sm-12 col-md-3 top-cart-row no-margin">
                        <div class="top-cart-row-container">
                            <div class="wishlist-compare-holder">
                                <div class="wishlist ">
                                    <a href="#"><i class="fa fa-heart"></i> 心愿单 <span class="value">(<?php echo $isGuest == 1 ? 0 : 0; ?>)</span> </a>
                                </div>
                                <div class="compare">
                                    <a href="#"><i class="fa fa-exchange"></i> 关注单 <span class="value">(<?php echo $isGuest == 1 ? 0 : 0; ?>)</span> </a>
                                </div>
                            </div>

                            <!-- ============================================================= SHOPPING CART DROPDOWN ============================================================= -->
                            <div class="top-cart-holder dropdown animate-dropdown">

                                <div class="basket">

                                    <a class="dropdown-toggle" data-toggle="dropdown" href="<?php echo Url::toRoute('cart') ?>">
                                        <div class="basket-item-count">
                                            <span id="cartCount" class="count"><?php echo $isGuest == 1 ? 0 : $cartCount ?></span>
                                            <img src="<?= Yii::$app->urlManager->baseUrl ?>/assets/images/icon-cart.png" alt="" />
                                        </div>

                                        <div class="total-price-basket"> 
                                            <span class="lbl">我的购物车:</span>
                                            <span class="total-price">
                                                <span class="sign" >￥</span>
                                                <span class="value" id="cartTotal"><?php echo $isGuest == 1 ? 0 : $cartTotal; ?></span>
                                            </span>
                                        </div>
                                    </a>

                                    <ul class="dropdown-menu">
										<?php
										if (!$isGuest) {
											foreach ($cartList as $cartUnit) {
												?>
												<li id = "dropdownProduct<?php echo $cartUnit['productId'] ?>">
													<div class="basket-item">
														<div class="row">
															<div class="col-xs-4 col-sm-4 no-margin text-center">
																<div class="thumb">
																	<img alt="" src="//<?php echo $cartUnit['productCover'] ?>" />
																</div>
															</div>
															<div class="col-xs-8 col-sm-8 no-margin">
																<div class="title"><?php echo $cartUnit['productTitle'] ?></div>
																<div class="price"><?php echo $cartUnit['productTotal'] ?></div>
															</div>
														</div>
														<button class="close-btn btn btn-default" 
																onclick="doDelete(<?php echo $cartUnit['productId'] ?>,
																<?php echo $cartUnit['productnum'] ?>,
																<?php echo $cartUnit['price'] ?>
																		)"></button>
													</div>
												</li>
												<?php
											}
										}
										?>
                                        <li class="checkout">
                                            <div class="basket-item">
                                                <div class="row">
                                                    <div class="col-xs-12 col-sm-6">
                                                        <a href="<?php echo Url::toRoute('cart/index') ?>" class="le-button inverse">查看购物车</a>
                                                    </div>
                                                    <div class="col-xs-12 col-sm-6">
                                                        <a href="<?php echo Url::toRoute('cart/index') ?>" class="le-button">结算</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>

                                    </ul>
                                </div><!-- /.basket -->
                            </div><!-- /.top-cart-holder -->
                        </div><!-- /.top-cart-row-container -->
                        <!-- ============================================================= SHOPPING CART DROPDOWN : END ============================================================= -->		</div><!-- /.top-cart-row -->
                </div><!-- /.container -->

                <!-- ========================================= NAVIGATION ========================================= -->
                <nav id="top-megamenu-nav" class="megamenu-vertical animate-dropdown">
                    <div class="container col-xs-16">
                        <div class="yamm navbar">
                            <div class="navbar-header">
                                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mc-horizontal-menu-collapse">
                                    <span class="sr-only">Toggle navigation</span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                </button>
                            </div><!-- /.navbar-header -->
                            <div class="col-xs-1"> </div>
                            <div class="collapse navbar-collapse col-xs-10" id="mc-horizontal-menu-collapse">
                                <ul class="nav navbar-nav">
									<?php
									foreach ($categoryList as $key => $categoryUnit) {
										?>
										<li class="dropdown">
											<a href="#" class="dropdown-toggle" data-hover="dropdown" 
											   data-toggle="dropdown"><?php echo $categoryUnit[0];
										?></a>
											<ul class="dropdown-menu">
												<li><div class="yamm-content">
														<div class="row">
															<div class="col-xs-12 col-sm-8">
																<!--                                                                <h2>Laptops &amp; Notebooks</h2>-->
																<ul>
																	<?php
																	foreach ($categoryUnit[1] as $UnitKey => $value) {
																		?>
																		<li><a href="<?php
																			echo Url::toRoute(['product/search', 'categoryId' =>
																				$UnitKey]);
																			?>"><?php echo $value['title'] ?></a></li>
																		<?php }
																		?>
																</ul>
															</div><!-- /.col -->
														</div><!-- /.row -->
													</div><!-- /.yamm-content --></li>
											</ul>
										</li>
									<?php } ?>
                                </ul>
                                </li>
                                </ul><!-- /.navbar-nav -->
                            </div><!-- /.navbar-collapse -->
                            <div class="col-xs-1"> </div>
                        </div><!-- /.navbar -->
                    </div><!-- /.container -->
                </nav><!-- /.megamenu-vertical -->
                <!-- ========================================= NAVIGATION : END ========================================= -->
                <div class="animate-dropdown"><!-- ========================================= BREADCRUMB ========================================= -->
                    <div id="breadcrumb-alt">
                        <div class="container">
                            <div class="breadcrumb-nav-holder minimal">
                                <ul>

                                </ul>
                            </div><!-- /.breadcrumb-nav-holder -->
                        </div><!-- /.container -->
                    </div><!-- /#breadcrumb-alt -->
                    <!-- ========================================= BREADCRUMB : END ========================================= --></div>
            </header>
            <!-- ============================================================= HEADER : END ============================================================= -->		
            <!-- ========================================= MAIN ========================================= -->
            <div class="container">
				<?= $content ?>
            </div>
            <!-- ========================================= MAIN : END ========================================= -->		
            <!-- ============================================================= FOOTER ============================================================= -->
            <footer id="footer" class="color-bg">

                <div class="container">
                    <div class="row no-margin widgets-row">
                        <div class="col-xs-12  col-sm-4 no-margin-left">
                            <!-- ============================================================= FEATURED PRODUCTS ============================================================= -->
                            <div class="widget">
                                <h2>口碑商品</h2>
                                <div class="body">
                                    <ul>
										<?php
										$productList = $this->params['productList'];
										foreach ($productList['tui'] as $productUnit) {
											?>
											<li>
												<div class="row">
													<div class="col-xs-12 col-sm-9 no-margin">
														<a href="<?php echo Url::toRoute(['product/view', 'id' => $productUnit->productId]); ?>"><?php echo $productUnit->title ?></a>
														<div class="price">
															<div class="price-prev"><?php echo $productUnit->price ?></div>
															<div class="price-current"><?php echo $productUnit->saleprice ?></div>
														</div>
													</div>  

													<div class="col-xs-12 col-sm-3 no-margin">
														<a href="<?php echo Url::toRoute(['product/view', 'id' => $productUnit->productId]); ?>" class="thumb-holder">
															<img alt="" src="//<?php echo $productUnit->cover; ?>" />
														</a>
													</div>
												</div>
											</li>  
										<?php } ?>
                                    </ul>
                                </div><!-- /.body -->
                            </div> <!-- /.widget -->
                            <!-- ============================================================= FEATURED PRODUCTS : END ============================================================= -->            </div><!-- /.col -->

                        <div class="col-xs-12 col-sm-4 ">
                            <!-- ============================================================= ON SALE PRODUCTS ============================================================= -->
                            <div class="widget">
                                <h2>上架商品</h2>
                                <div class="body">
                                    <ul>
										<?php
										$productList = $this->params['productList'];
										foreach ($productList['new'] as $productUnit) {
											?>
											<li>
												<div class="row">
													<div class="col-xs-12 col-sm-9 no-margin">
														<a href="<?php echo Url::toRoute(['product/view', 'id' => $productUnit->productId]); ?>"><?php echo $productUnit->title ?></a>
														<div class="price">
															<div class="price-prev"><?php echo $productUnit->price ?></div>
															<div class="price-current"><?php echo $productUnit->saleprice ?></div>
														</div>
													</div>  

													<div class="col-xs-12 col-sm-3 no-margin">
														<a href="<?php echo Url::toRoute(['product/view', 'id' => $productUnit->productId]); ?>" class="thumb-holder">
															<img alt="" src="//<?php echo $productUnit->cover; ?>" />
														</a>
													</div>
												</div>
											</li>  
										<?php } ?>
                                    </ul>
                                </div><!-- /.body -->
                            </div> <!-- /.widget -->
                            <!-- ============================================================= ON SALE PRODUCTS : END ============================================================= -->            </div><!-- /.col -->

                        <div class="col-xs-12 col-sm-4 ">
                            <!-- ============================================================= TOP RATED PRODUCTS ============================================================= -->
                            <div class="widget">
                                <h2>折扣商品</h2>
                                <div class="body">
                                    <ul>
										<?php
										$productList = $this->params['productList'];
										foreach ($productList['hot'] as $productUnit) {
											?>
											<li>
												<div class="row">
													<div class="col-xs-12 col-sm-9 no-margin">
														<a href="<?php echo Url::toRoute(['product/view', 'id' => $productUnit->productId]); ?>"><?php echo $productUnit->title ?></a>
														<div class="price">
															<div class="price-prev"><?php echo $productUnit->price ?></div>
															<div class="price-current"><?php echo $productUnit->saleprice ?></div>
														</div>
													</div>  

													<div class="col-xs-12 col-sm-3 no-margin">
														<a href="<?php echo Url::toRoute(['product/view', 'id' => $productUnit->productId]); ?>" class="thumb-holder">
															<img alt="" src="//<?php echo $productUnit->cover; ?>" />
														</a>
													</div>
												</div>
											</li>  
										<?php } ?>
                                    </ul>
                                </div><!-- /.body -->
                            </div><!-- /.widget -->
                            <!-- ============================================================= TOP RATED PRODUCTS : END ============================================================= -->            </div><!-- /.col -->

                    </div><!-- /.widgets-row-->
                </div><!-- /.container -->

                <!--                <div class="sub-form-row">
                                    <div class="container">
                                        <div class="col-xs-12 col-sm-8 col-sm-offset-2 no-padding">
                                            <form role="form">
                                                <input placeholder="Subscribe to our newsletter">
                                                <button class="le-button">Subscribe</button>
                                            </form>
                                        </div>
                                    </div> /.container 
                                </div> /.sub-form-row -->

                <div class="link-list-row">
                    <div class="container no-padding">
                        <div class="col-xs-12 col-md-4 ">
						</div>

                        <div class="col-xs-12 col-md-8 no-margin">
						</div>
                    </div><!-- /.container -->
                </div><!-- /.link-list-row -->

                <div class="copyright-bar">
                    <div class="container">
                        <div class="col-xs-12 col-sm-6 no-margin">
                            <div class="copyright">
                                &copy; <a href="<?= Yii::$app->urlManager->baseUrl ?>/site/index"><?php echo Yii::$app->name; ?></a> - all rights reserved
                            </div><!-- /.copyright -->
                        </div>
                        <div class="col-xs-12 col-sm-6 no-margin">
                            <div class="payment-methods ">
                                <ul>
                                    <li><img alt="" src="<?= Yii::$app->urlManager->baseUrl ?>/assets/images/payments/payment-visa.png"></li>
                                    <li><img alt="" src="<?= Yii::$app->urlManager->baseUrl ?>/assets/images/payments/payment-master.png"></li>
                                    <li><img alt="" src="<?= Yii::$app->urlManager->baseUrl ?>/assets/images/payments/payment-paypal.png"></li>
                                    <li><img alt="" src="<?= Yii::$app->urlManager->baseUrl ?>/assets/images/payments/payment-skrill.png"></li>
                                </ul>
                            </div><!-- /.payment-methods -->
                        </div>
                    </div> <!--/.container -->
                </div><!-- /.copyright-bar -->

            </footer><!-- /#footer -->
            <!-- ============================================================= FOOTER : END ============================================================= -->	</div><!-- /.wrapper -->


        <!-- JavaScripts placed at the end of the document so the pages load faster -->
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/jquery-1.10.2.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/jquery-migrate-1.2.1.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/bootstrap.min.js"></script>
        <!--<script src="<?= Yii::$app->urlManager->baseUrl ?>/http://maps.google.com/maps/api/js?sensor=false&amp;language=en"></script>-->
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/gmap3.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/bootstrap-hover-dropdown.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/owl.carousel.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/css_browser_selector.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/echo.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/jquery.easing-1.3.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/bootstrap-slider.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/jquery.raty.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/jquery.prettyPhoto.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/jquery.customSelect.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/wow.min.js"></script>
        <script src="<?= Yii::$app->urlManager->baseUrl ?>/assets/js/scripts.js"></script>

        <!-- For demo purposes – can be removed on production -->

        <script src="<?= Yii::$app->urlManager->baseUrl ?>/switchstylesheet/switchstylesheet.js"></script>

        <script type="text/javascript">
															$(document).ready(function () {
																$(".changecolor").switchstylesheet({seperator: "color"});
																$('.show-theme-options').click(function () {
																	$(this).parent().toggleClass('open');
																	return false;
																});
															});

															$(window).bind("load", function () {
																$('.show-theme-options').delay(2000).trigger('click');
															});
		</script>
		<script>

			function doSearch()
			{
//				alert("productSearch");
				var myForm = document.getElementById("productSearch");
				myForm.submit();
			}

			function  doDelete(productId, number, price) {
				var csrfToken = "<?php echo Yii::$app->request->csrfToken; ?>";
				$.ajax({
					type: "POST",
					url: '<?php echo Yii::$app->request->baseUrl . '/cart/remove'; ?>',
					data: {id: productId, number: 1, _csrf: csrfToken},
					success: function (data) {
						var product = document.getElementById("product" + productId);
						if (product !== null) {
							product.style.display = 'none';
						}
						var dropdownProduct = document.getElementById("dropdownProduct" + productId);
						dropdownProduct.style.display = 'none';
						var cartCount = document.getElementById("cartCount");
						cartCount.innerHTML = parseInt(cartCount.innerHTML) - 1;
						var cartTotal = document.getElementById("cartTotal");
						cartTotal.innerHTML = parseInt(cartTotal.innerHTML) - number * price;
						console.log(data);
					},
					error: function (data) {
						alert("添加失败");
						console.log(data);
					},
				});
			}
		</script>
        <!-- For demo purposes – can be removed on production : End -->

        <script src="<?= Yii::$app->urlManager->baseUrl ?>/http://w.sharethis.com/button/buttons.js"></script>

    </body>
</html>